package com.woniuxy.woniuhis.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.woniuxy.woniuhis.entity.PayOut;
import com.woniuxy.woniuhis.exception.PayOutServiceException;
import com.woniuxy.woniuhis.mapper.PayOutMapper;
import com.woniuxy.woniuhis.service.PayOutService;
@Service
public class PayOutServiceImpl implements PayOutService{
	@Autowired
	PayOutMapper payOutMapper;
	@Override
	//添加付款订单
	public void addPayOut(PayOut payOut) {
		try {
			payOutMapper.insertPayOut(payOut);
		} catch (Exception e) {
			e.printStackTrace();
			throw new PayOutServiceException();
		}	
	}

	@Override
	//删除付款订单
	public void delPayOutById(String payOutId) {
		try {
			payOutMapper.deletePayOutById(payOutId);
		} catch (Exception e) {
			e.printStackTrace();
			throw new PayOutServiceException();
		}			
	}

	@Override
	//修改付款订单
	public void modifyPayOut(PayOut payOut) {
		try {
			payOutMapper.updatePayOut(payOut);
		} catch (Exception e) {
			e.printStackTrace();
			throw new PayOutServiceException();
		}			
	}

	@Override
	//按照id查找付款订单
	public PayOut findPayOutById(String payOutId) {
		try {
			PayOut payOut = payOutMapper.selectPayOutById(payOutId);
			return payOut;
		} catch (Exception e) {
			e.printStackTrace();
			throw new PayOutServiceException();
		}			
	}
	
	@Override
	//按照条件查找付款订单
	public List<PayOut> findPayOut(PayOut payOut, Date beginDate, Date endDate) {
		try {
			List<PayOut> payOuts = payOutMapper.selectPayOut(payOut, beginDate, endDate);
			return payOuts;
		} catch (Exception e) {
			e.printStackTrace();
			throw new PayOutServiceException();
		}			
	}

}
